// 导航守卫和根据不同的用户展示左侧左侧不同的菜单

import {lazy} from "react"
import {Navigate} from "react-router-dom"
const Login = lazy(()=>import("../pages/Login"))
const Home = lazy(()=>import("../pages/Home/Home"))
const Person = lazy(()=>import("../pages/Home/Person"))
const Exam = lazy(()=>import("../pages/Home/Exam"))
const Exercise = lazy(()=>import("../pages/Home/Exercise"))
const Data = lazy(()=>import("../pages/Home/Data"))
const NotFind = lazy(()=>import("../pages/Notfind"))
export const adminchild = [
    {
        path:"/home/person",
        element:<Person></Person>,
        tit:"人员管理"
    },
    {
        path:"/home/exam",
        element:<Exam></Exam>,
        tit:"考务管理"
    },
    {
        path:"/home/exercise",
        element:<Exercise></Exercise>,
        tit:"练习管理"
    },
    {
        path:"/home/data",
        element:<Data></Data>,
        tit:"数据管理"

    }
]
export const userchild = [
    {
        path:"/home/person",
        element:<Person></Person>,
        tit:"人员管理"
    },
    {
        path:"/home/exam",
        element:<Exam></Exam>,
        tit:"考务管理"
    },
    {
        path:"/home/data",
        element:<Data></Data>,
        tit:"数据管理"

    }
]
const routerconfig = [
    {
        path:"/login",
        element:<Login></Login>
    },

    {
        path:"/home",
        element:<Home></Home>,
        children:window.localStorage.getItem("user") === "admin" ? adminchild : userchild
    },
    
    {
        path:"/",
        element:<Navigate to="/login"></Navigate>
    },
    {   
        path:"*",
        element:<NotFind></NotFind>

    }
]
export default routerconfig